import java.io.*;
import java.net.Socket;


public class TCPServerThreadClient extends Thread{
	private Socket socket;
    private String line,input;
    
    public TCPServerThreadClient(Socket socket)
    {
    	this.socket=socket;
    }
    
    public void run () {

        input="";

        try {
          // Get input from the client
          DataInputStream in = new DataInputStream (socket.getInputStream());
          PrintStream out = new PrintStream(socket.getOutputStream());

          while((line = in.readLine()) != null && !line.equals(".")) {
            input=input + line;
            out.println("I got:" + line);
          }

          // Now write to the client

          System.out.println("Overall message is:" + input);
          out.println("Overall message is:" + input);

          socket.close();
        } catch (IOException ioe) {
          System.out.println("IOException on socket listen: " + ioe);
          ioe.printStackTrace();
        }
      }
}
